﻿using FluentNHibernate;
using PAP.Domain.UserAccount.Entities;
using PAP.Infrastructure.DataAccess.NH.Mappings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PAP.Infrastructure.DataAccess.NH.Domain.Mappings.UserAccount
{
    public class UserMap : EntityMap<User>
    {
        public UserMap()
            : base()
        {
            Table("[User]");
            Map(x => x.AddDate, "AddDate")
                .Not.Nullable();
            Map(x => x.ModifyDate, "ModifyDate")
                .Nullable();
            Map(x => x.Login, "Login")
                .Length(40)
                .Not.Nullable();
            Map(x => x.Password, "Password")
                .Length(30)
                .Not.Nullable();

            Map(Reveal.Member<User>("_salt"), "Salt");

            Component(x => x.Name, m =>
                {
                    m.Map(x => x.Firstname, "Firstname")
                        .Length(40)
                        .Not.Nullable();
                    m.Map(x => x.Lastname, "Lastname")
                        .Length(60)
                        .Not.Nullable();
                });
        }
    }
}
